package com.hiq.gene.util;

public class StringUtil {
    public static String getDBName(String className) {
        StringBuffer buffer = new StringBuffer();
        char[] chars = className.toCharArray();
        for (int i = 0; i < chars.length; i++) {
           String s = String.valueOf(chars[i]);
           String b = s.toUpperCase();
           if (b.equals(s) && i > 0) {
              buffer.append("_");
           }
           buffer.append(b);
        }
        return buffer.toString();
    }

    public static String getGetterName(String fieldName, boolean isBoolean) {
       return "get" + toMethodName(fieldName);
    }

    public static String getSetterName(String fieldName) {
       return "set" + toMethodName(fieldName);
    }

    private static String toMethodName(String fieldName) {
        return fieldName.toUpperCase().substring(0, 1) + fieldName.substring(1);
    }
}
